package com.roc.web.action.yycard;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

@SuppressWarnings("serial")
public class ScanCodeActionSearchCondition extends BaseSearchCondition{

	private String mcthCd;
	private String name;
	private String opId;
	private String wx;
	private String zfb;
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(mcthCd))
		{
			filedBeanList.add(new WhereHQLFieldBean("s.mcht_cd", mcthCd.trim(),"=", false));
		}
		if(Constance.isNotEmpty(name))
		{
			filedBeanList.add(new WhereHQLFieldBean("s.name", name.trim(),
					"LIKE", false, "ALL"));
		}
		if(Constance.isNotEmpty(opId)){
			filedBeanList.add(new WhereHQLFieldBean("s.ext1",opId.trim(),"=",false));
		}
		if(Constance.isNotEmpty(wx)){
			if("00".equals(Constance.Null2EmptyTrim(wx))){
				filedBeanList.add(new WhereHQLFieldBean("t.remark3 is null"));
			}else if("1".equals(Constance.Null2EmptyTrim(wx)) || "4".equals(Constance.Null2EmptyTrim(wx))){
				filedBeanList.add(new WhereHQLFieldBean("t.remark3",wx.trim(),"=",false));
			}else{
				filedBeanList.add(new WhereHQLFieldBean("t.remark3 in ('0','2','3') "));
			}
		}
		if(Constance.isNotEmpty(zfb)){
			if("2".equals(Constance.Null2EmptyTrim(zfb))){
				filedBeanList.add(new WhereHQLFieldBean("t.remark2 is null"));
			}else{
				filedBeanList.add(new WhereHQLFieldBean("t.remark2",zfb.trim(),"=",false));
			}			
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb = new StringBuffer();
		sb.append(" select count(*) from tbl_mcht_inf s,apstfr.tbl_mcht_contact t,t_wx_audit a where s.mcht_cd = t.mchtcd(+) and s.mcht_cd=a.mcht_cd(+) ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb = new StringBuffer();
		sb.append("select s.mcht_cd,s.name,t.remark2,t.remark3,s.busi_lice_no,s.reg_addr,s.contact_name,s.contact_phoneno,a.audit_opinion,a.status,s.ext1,a.wx_subid "
				+ " from tbl_mcht_inf s,apstfr.tbl_mcht_contact t,t_wx_audit a where s.mcht_cd = t.mchtcd(+) and s.mcht_cd=a.mcht_cd(+) ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {		
		return "order by s.appl_date desc";
	}

	public String getMcthCd() {
		return mcthCd;
	}

	public void setMcthCd(String mcthCd) {
		this.mcthCd = mcthCd;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getOpId() {
		return opId;
	}

	public void setOpId(String opId) {
		this.opId = opId;
	}

	public String getWx() {
		return wx;
	}

	public void setWx(String wx) {
		this.wx = wx;
	}

	public String getZfb() {
		return zfb;
	}

	public void setZfb(String zfb) {
		this.zfb = zfb;
	}
	
}
